Array.prototype.reverse = function() {
	var result = []
	for (var idx = this.length - 1; idx >= 0; idx--)
		result.push(this[idx]);
	return result;
}

Array.prototype.shift = function() {
	if (this.length > 0) {
		var rv = this[0];
		this.splice(0, 1);
		return rv;
	} else {
		return null
	}
}

Array.prototype.slice = function(begin, end) {
	var result = []
	var len = this.length
	if (end == null)
		end = this.length;
	if (begin < 0)
		begin = 0;
	for (var idx = begin; idx < end && idx < len; idx++)
		result.push(this[idx]);
	return result;
}

Array.prototype.map = function(fn) {
	var result = []
	var len = this.length
	for (var idx = 0; idx < len; idx++)
		result.push(fn(this[idx]))
	return result
}

Array.prototype.filter = function(fn) {
	var result = []
	var len = this.length
	for (var idx = 0; idx < len; idx++) {
		var item = this[idx]
		if (fn(item))
			result.push(item)
	}
	return result
}

Array.prototype.indexOf = function(item) {
	var len = this.length
	
	for (var idx = 0; idx < len; idx++) {
		if (this[idx] == item)
			return idx;
	}
	return -1
}

Array.prototype.lastIndexOf = function(item) {
	var len = this.length

	for (var idx = len - 1; idx >= 0; idx--) {
		if (this[idx] == item)
			return idx;
	}
	return -1
}
